home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0046_Trapping Runtime Errors.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  982b  |  45 lines

  1. {
  2. JON JASIUNAS
  3.  
  4. I never use them. if a Program bombs because a disk is full, I just
  5. > catch the run-time error in an Exit proc and report so (I/O-checking
  6. > must be set on, of course).
  7.  
  8. >I am curious, How do you go about Catching the Run-Time Error. Doesn't it
  9. >just say Runtime Error 103 ?????:?????
  10.  
  11. You can catch the run-time errors by linking into the Exit chain.
  12. Here's a small example:
  13. }
  14.  
  15. Unit ErrTrap;
  16.  
  17. Interface
  18.  
  19. Implementation
  20.  
  21. Var
  22.   OldExit : Pointer;
  23.  
  24. Procedure NewExit; Far;  { MUST be far! }
  25. begin
  26.   if ErrorAddr <> nil then
  27.   begin
  28.     {-Display custom run-time error message }
  29.     WriteLn('Fatal error #', ExitCode);
  30.     WriteLn('Address = ', Seg(ErrorAddr^), ':', Ofs(ErrorAddr^));
  31.     {-Cancel run-time error so you don't get the default message, too }
  32.     ErrorAddr := nil;
  33.     {-Zero the errorlevel }
  34.     ExitCode  := 0;
  35.   end;
  36.   ExitProc := OldExit;
  37. end;
  38.  
  39. begin
  40.   OldExit  := ExitProc;
  41.   ExitProc := @NewExit;
  42. end.
  43.  
  44.  
  45.